<template>
	<view class="content">
		<image class="long" :src="buildInfo.thumb" mode="aspectFill"></image>
		<view class="header-content">
			<view class="header-left">
				<view class="line"></view>
				<text class="header-title">基本信息</text>
			</view>
			<image class="header-content-share" src="../../../static/images/icon/share_icon.png"></image>
		</view>
		<view class="model_list">
			<text class="model_name">地&emsp;&emsp;区</text>
			<text class="model_value">{{buildInfo.area.name}}</text>
			<text class="model_name">楼盘名称</text>
			<text class="model_value">{{buildInfo.name}}</text>
			<text class="model_name">户&emsp;&emsp;型</text>
			<text class="model_value">{{buildInfo.model.name}}</text>
		</view>
		<view class="header-content">
			<view class="header-left">
				<view class="line"></view>
				<text class="header-title">地理位置</text>
			</view>
		</view>
		<map @click.stop="goMapdeatils" style="width: 670rpx;  height: 670rpx;" :latitude="buildInfo.latitude"
			:longitude="buildInfo.longitude" :markers="covers" :show-location="true">
		</map>
		<view class="header-content">
			<view class="header-left">
				<view class="line"></view>
				<text class="header-title">案例展示</text>
			</view>
		</view>
		<view class="model-list" @click="gotoPage('/pages/index/details/show/show')">
			<view class="model-item">
				<image class="model-item-image" src="../../../static/images/common/tancheng.png"></image>
				<view class="model-item-mark"><text class="model-item-size">30m²</text></view>
			</view>
			<view class="model-item">
				<image class="model-item-image" src="../../../static/images/common/tancheng.png"></image>
				<view class="model-item-mark"><text class="model-item-size">80m²</text></view>
			</view>
			<view class="model-item">
				<image class="model-item-image" src="../../../static/images/common/tancheng.png"></image>
				<view class="model-item-mark"><text class="model-item-size">30m²</text></view>
			</view>
			<view class="model-item">
				<image class="model-item-image" src="../../../static/images/common/tancheng.png"></image>
				<view class="model-item-mark"><text class="model-item-size">80m²</text></view>
			</view>
		</view>
		<button class="submit">确定预约</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: 0,
				title: 'map',
				latitude: 28.107713813889387,
				longitude: 112.96185187776567,
				covers: [{
					latitude: 28.107713813889387,
					longitude: 112.96185187776567,
					iconPath: '../../static/images/icon/markers.png'
				}],
				buildInfo: {
					area: '',
					model: ''
				},
				covers: []

			}
		},
		onLoad() {},
		methods: {
			gotoPage(path) {
				uni.navigateTo({
					url: path
				});
			},
			goMapdeatils() {
				console.log('测试');
				uni.openLocation({
					latitude: parseFloat(this.buildInfo.latitude),
					longitude: parseFloat(this.buildInfo.longitude),
					name: this.buildInfo.name,
					success: function() {
						console.log('导航成功');
					},
					fail: function(error) {
						console.log(error);
					}
				})
			}
		},
		onLoad(e) {
			console.log(e.id);
			uni.request({
				url: "https://baiyi.kent.work/api/v1/system/getBuildDetail",
				method: "post",
				data: {
					id: e.id,

				},
				success: (res) => {
					console.log(res.data.data.buildInfo);
					this.buildInfo = res.data.data.buildInfo
					this.covers = [{
						"latitude": this.buildInfo.latitude,
						"longitude": this.buildInfo.longitude,
						"width": 30,
						"height": 30,
						"iconPath": "../../../static/images/icon/markers.png"
					}]
				},

			})
		}
	};
</script>

<style>
	page {
		background-color: #f5f5f5;
	}

	.content {
		box-sizing: border-box;
		width: 100vw;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.long {
		width: 100vh;
		height: 450rpx;
	}

	.model_list {
		box-sizing: border-box;
		font-size: 28rpx;
		grid-row-gap: 20rpx;
		padding: 0rpx 40rpx;
		width: 100%;
		display: grid;
		grid-template-columns: 40% 1fr;
	}

	.header-content {
		box-sizing: border-box;
		width: 100%;
		display: flex;
		align-items: center;
		padding: 40rpx 40rpx 26rpx 40rpx;
		justify-content: space-between;
	}

	.header-left {
		display: flex;
		align-items: center;
	}

	.header-title {
		font-family: PingFang SC, PingFang SC-Bold;
		color: #333333;
		font-size: 32rpx;
		font-weight: 700;
		margin-left: 20rpx;
	}

	.header-content-share {
		width: 38rpx;
		height: 38rpx;
	}

	.line {
		width: 8rpx;
		height: 30rpx;
		background: #3d9c36;
	}

	.model_name {
		font-family: PingFang SC, PingFang SC-Medium;
		color: #333333;
		font-size: 24rpx;
	}

	.model_value {
		font-family: PingFang SC, PingFang SC-Bold;
		color: #333333;
		font-size: 24rpx;
		font-weight: bold;
	}

	.model-list {
		box-sizing: border-box;
		display: grid;
		grid-template-columns: 1fr 1fr;
		grid-gap: 22rpx;
		padding: 0 40rpx;
		width: 100%;
	}

	.model-item {
		position: relative;
		border-radius: 16rpx;
		box-shadow: 0rpx 4rpx 2rpx rgba(0, 0, 0, 0.1);
	}

	.model-item-image {
		width: 100%;
		height: 200rpx;
	}

	.model-item-mark {
		position: absolute;
		width: 100%;
		height: 50rpx;
		background-color: white;
		bottom: 0;
		border-radius: 0 0 16rpx 16rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.model-item-size {
		font-family: PingFang SC, PingFang SC-Bold;
		font-size: 28rpx;
	}

	.model-item-size::before {
		content: '— ';
		color: #3d9c36;
	}

	.model-item-size::after {
		content: ' —';
		color: #3d9c36;
	}

	.submit {
		box-sizing: border-box;
		height: 80rpx;
		width: 328rpx;
		color: #fff;
		font-size: 32rpx;
		background-color: #3d9c36;
		margin: 80rpx;
	}
</style>